.class Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$b;
.super Ljava/lang/Object;
.source "RequestResponseManager.java"

# interfaces
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->processClickInBackground(Landroid/content/Context;)V
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation


# instance fields
.field final synthetic a:Landroid/content/Context;

.field final synthetic b:Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;


# direct methods
.method constructor <init>(Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;Landroid/content/Context;)V
    .locals 0
    .parameter
    .parameter

    .prologue
    .line 286
    iput-object p1, p0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$b;->b:Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;

    iput-object p2, p0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$b;->a:Landroid/content/Context;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method


# virtual methods
.method public run()V
    .locals 15

    .prologue
    .line 290
    :cond_0
    sget-object v0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->isSynced:Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicBoolean;->get()Z

    move-result v0

    if-nez v0, :cond_a

    .line 291
    sget-object v0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->isSynced:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Ljava/util/concurrent/atomic/AtomicBoolean;->set(Z)V

    .line 293
    sget-object v0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->mClickEventList:Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;

    if-eqz v0, :cond_1

    sget-object v0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->mClickEventList:Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;

    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;->isEmpty()Z

    move-result v0

    if-eqz v0, :cond_4

    .line 295
    :cond_1
    const-string v0, "InMobiAndroidSDK_3.7.0"

    const-string v1, "Click event list empty"

    invoke-static {v0, v1}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;)V

    .line 296
    iget-object v0, p0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$b;->b:Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;

    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->deinit()V

    .line 400
    :goto_0
    return-void

    .line 347
    :cond_2
    :try_start_0
    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEvent;->isFirstClick()Z

    move-result v0

    if-nez v0, :cond_3

    invoke-static {}, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->a()Ljava/util/concurrent/atomic/AtomicBoolean;

    move-result-object v0

    invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicBoolean;->get()Z

    move-result v0

    if-nez v0, :cond_3

    .line 349
    const-string v0, "InMobiAndroidSDK_3.7.0"

    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    const-string v9, "Retrying to ping in background after "

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    div-int/lit16 v9, v7, 0x3e8

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, " secs"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-static {v0, v8}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;)V

    .line 350
    sget-object v8, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->a:Ljava/lang/Thread;

    monitor-enter v8
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 352
    :try_start_1
    sget-object v0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->a:Ljava/lang/Thread;

    int-to-long v11, v7

    invoke-virtual {v0, v11, v12}, Ljava/lang/Object;->wait(J)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0
    .catch Ljava/lang/InterruptedException; {:try_start_1 .. :try_end_1} :catch_1

    .line 357
    :goto_1
    :try_start_2
    monitor-exit v8
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 359
    :cond_3
    :try_start_3
    const-string v0, "InMobiAndroidSDK_3.7.0"

    new-instance v7, Ljava/lang/StringBuilder;

    invoke-direct {v7}, Ljava/lang/StringBuilder;-><init>()V

    const-string v8, "Processing click in background: "

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    invoke-static {v0, v7}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;)V

    .line 362
    if-eqz v3, :cond_8

    .line 364
    iget-object v0, p0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$b;->b:Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;

    iget-object v3, p0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$b;->a:Landroid/content/Context;

    invoke-virtual/range {v0 .. v6}, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->processClickUrlInWebview(ILjava/lang/String;Landroid/content/Context;Ljava/lang/ref/WeakReference;IZ)Z

    move-result v0

    if-eqz v0, :cond_7

    .line 367
    const-string v0, "InMobiAndroidSDK_3.7.0"

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "Ping in webview successful: "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v0, v2}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;)V

    .line 369
    sget-object v0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->mClickEventList:Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;

    invoke-virtual {v0, v1}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;->removeClickEvent(I)Z

    .line 300
    :cond_4
    :goto_2
    sget-object v0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->mClickEventList:Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;

    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;->isEmpty()Z

    move-result v0

    if-nez v0, :cond_0

    .line 303
    sget-object v0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->mClickEventList:Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEvent;

    .line 304
    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEvent;->getClickURL()Ljava/lang/String;

    move-result-object v2

    .line 305
    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEvent;->getRetryCount()I

    move-result v5

    .line 306
    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEvent;->isPingWV()Z

    move-result v3

    .line 307
    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEvent;->isFollowRedirects()Z

    move-result v10

    .line 309
    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEvent;->getClickId()I

    move-result v1

    .line 310
    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEvent;->isFirstClick()Z

    move-result v6

    .line 311
    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEvent;->getWebviewRef()Ljava/lang/ref/WeakReference;

    move-result-object v4

    .line 313
    invoke-static {}, Lcom/inmobi/commons/internal/InternalSDKUtil;->getContext()Landroid/content/Context;

    move-result-object v7

    invoke-static {v7}, Lcom/inmobi/androidsdk/bootstrapper/Initializer;->getConfigParams(Landroid/content/Context;)Lcom/inmobi/androidsdk/bootstrapper/ConfigParams;

    move-result-object v7

    invoke-virtual {v7}, Lcom/inmobi/androidsdk/bootstrapper/ConfigParams;->getImai()Lcom/inmobi/androidsdk/bootstrapper/IMAIConfigParams;

    move-result-object v7

    invoke-virtual {v7}, Lcom/inmobi/androidsdk/bootstrapper/IMAIConfigParams;->getRetryInterval()I

    move-result v7

    .line 315
    iget-object v8, p0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$b;->a:Landroid/content/Context;

    invoke-static {v8}, Lcom/inmobi/commons/internal/InternalSDKUtil;->checkNetworkAvailibility(Landroid/content/Context;)Z

    move-result v8

    if-nez v8, :cond_2

    .line 317
    const-string v0, "InMobiAndroidSDK_3.7.0"

    const-string v5, "Cannot process click. Network Not available"

    invoke-static {v0, v5}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;)V

    .line 322
    new-instance v0, Lcom/inmobi/androidsdk/impl/net/HttpRequestCallback$ResponseStatus;

    invoke-direct {v0}, Lcom/inmobi/androidsdk/impl/net/HttpRequestCallback$ResponseStatus;-><init>()V

    .line 323
    iput-object v2, v0, Lcom/inmobi/androidsdk/impl/net/HttpRequestCallback$ResponseStatus;->b:Ljava/lang/String;

    .line 324
    iput-object v4, v0, Lcom/inmobi/androidsdk/impl/net/HttpRequestCallback$ResponseStatus;->a:Ljava/lang/ref/WeakReference;

    .line 326
    if-eqz v6, :cond_5

    .line 327
    if-eqz v3, :cond_6

    .line 328
    sget-object v2, Lcom/inmobi/androidsdk/impl/imai/IMAIUtility;->mPingWebviewCallback:Lcom/inmobi/androidsdk/impl/net/HttpRequestCallback;

    const/4 v3, 0x1

    invoke-interface {v2, v3, v0}, Lcom/inmobi/androidsdk/impl/net/HttpRequestCallback;->notifyResult(ILjava/lang/Object;)V

    .line 342
    :cond_5
    :goto_3
    sget-object v0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->mClickEventList:Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;

    invoke-virtual {v0, v1}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;->resetFirstClick(I)V

    .line 343
    iget-object v0, p0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$b;->b:Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;

    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->deinit()V
    :try_end_3
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_0

    goto/16 :goto_0

    .line 393
    :catch_0
    move-exception v0

    .line 394
    const-string v1, "InMobiAndroidSDK_3.7.0"

    const-string v2, "Exception pinging click in background"

    invoke-static {v1, v2, v0}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    .line 395
    iget-object v0, p0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$b;->b:Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;

    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->deinit()V

    goto/16 :goto_0

    .line 333
    :cond_6
    :try_start_4
    sget-object v2, Lcom/inmobi/androidsdk/impl/imai/IMAIUtility;->mPingReqCallback:Lcom/inmobi/androidsdk/impl/net/HttpRequestCallback;

    const/4 v3, 0x1

    invoke-interface {v2, v3, v0}, Lcom/inmobi/androidsdk/impl/net/HttpRequestCallback;->notifyResult(ILjava/lang/Object;)V
    :try_end_4
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_0

    goto :goto_3

    .line 353
    :catch_1
    move-exception v0

    .line 354
    :try_start_5
    const-string v7, "InMobiAndroidSDK_3.7.0"

    const-string v9, "Network thread wait failure"

    invoke-static {v7, v9, v0}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    goto/16 :goto_1

    .line 357
    :catchall_0
    move-exception v0

    monitor-exit v8
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    :try_start_6
    throw v0

    .line 373
    :cond_7
    sget-object v0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->mClickEventList:Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;

    invoke-virtual {v0, v1}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;->reduceRetryCount(I)V

    .line 374
    const-string v0, "InMobiAndroidSDK_3.7.0"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "Ping in webview failed: "

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;)V

    goto/16 :goto_2

    .line 377
    :cond_8
    iget-object v7, p0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$b;->b:Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;

    iget-object v11, p0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$b;->a:Landroid/content/Context;

    move v8, v1

    move-object v9, v2

    move-object v12, v4

    move v13, v5

    move v14, v6

    invoke-virtual/range {v7 .. v14}, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->processClickHttpClient(ILjava/lang/String;ZLandroid/content/Context;Ljava/lang/ref/WeakReference;IZ)Z

    move-result v0

    if-eqz v0, :cond_9

    .line 381
    const-string v0, "InMobiAndroidSDK_3.7.0"

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "Ping successful: "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v0, v2}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;)V

    .line 383
    sget-object v0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->mClickEventList:Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;

    invoke-virtual {v0, v1}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;->removeClickEvent(I)Z

    goto/16 :goto_2

    .line 387
    :cond_9
    sget-object v0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->mClickEventList:Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;

    invoke-virtual {v0, v1}, Lcom/inmobi/androidsdk/impl/imai/IMAIClickEventList;->reduceRetryCount(I)V

    .line 388
    const-string v0, "InMobiAndroidSDK_3.7.0"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "Ping failed: "

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_6
    .catch Ljava/lang/Exception; {:try_start_6 .. :try_end_6} :catch_0

    goto/16 :goto_2

    .line 399
    :cond_a
    iget-object v0, p0, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$b;->b:Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;

    invoke-virtual {v0}, Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;->deinit()V

    goto/16 :goto_0
.end method
